/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.pablow.dao.serializables;

import com.pablow.dao.serializables.GenericDAOSer;
import com.pablow.model.User;
import java.io.Serializable;
import java.util.List;

/**
 *
 * @author Administrador
 */
public class UserDAOSer extends GenericDAOSer<User,Serializable> {

    @Override
    public User save(User user) {
        user.setId(System.currentTimeMillis());
        return this.persist(user);
    }

    @Override
    public List<User> getAll() {
        return this.getAll(User.class);
    }

    @Override
    public Boolean remove(User user) {
        return this.remove(user);
    }

    public User getUser(String userName,String password){
        List<User> users=this.getAll();
        User userSearched=null;
        for (User u:users){
            if (u.getUsername().equals(userName) && u.getPassword().equals(password)){
                userSearched=u;
                break;
            }
        }
        return userSearched;
    }

}
